package com.kele.web.vertx.consumer;

import com.kele.web.vertx.consumer.verticles.ConsumRestVerticle;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
import io.vertx.core.spi.cluster.ClusterManager;
import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager;

public class VertxConsumer {

    public static void main(String[] args) {
        ClusterManager mgr = new HazelcastClusterManager();
        VertxOptions options = new VertxOptions().setClusterManager(mgr);
        Vertx.clusteredVertx(options, res -> {
            if (res.succeeded()) {
                Vertx vertx = res.result();
                vertx.deployVerticle(ConsumRestVerticle.class, new DeploymentOptions().setWorker(true).setInstances(2));
            } else {
                // failed!
                System.out.println("vertx 集群模式启动失败");
            }
        });
    }
}
